
#include <serpent.h>

void s_free(void* p);

bool s_init(void) {
	objects = (obj_t**)calloc(1,sizeof(obj_t));
	if( NULL == objects )
		return(false);

		return(true);
}

bool s_exit(void) {
	/*
	 * stop_queues
	 * destroy_queues
	 *
	 */

	if( !destroy_queues() )
		return(false);

	return(true);
}

obj_t* create_obj(s_objtype type) {
	unsigned long long co = 0;
	obj_t* o = (obj_t*)calloc(1,sizeof(obj_t));
	if( NULL == o )
		return(false);

	while( NULL != objects[co] )
	{
		co++;
	}

	objects = (obj_t**)realloc(objects, sizeof(objects) + (sizeof(obj_t)));
	if( NULL == objects )
		return(NULL);

	objects[co] = o;

		return(o);
}

bool destroy_obj(obj_t* o) {
	if( NULL != o )
	{
		s_free(o);
		return(true);
	}
	else
	{
		return(false);
	}
}

void s_free(void* p)
{
	if( p != NULL )
	{
		free(p);
		p = NULL;
	}
}
